package com.fushenlan.epidemicControl.controller;

/**
 * @author PC
 * @title: UserController
 * @projectName SpringBootDemo
 * @description: TODO
 * @date 2021/8/14 18:29
 */

import com.fushenlan.epidemicControl.service.UserService;
import com.fushenlan.po.User;
import com.fushenlan.response.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("user")
@Api(value = "用户信息管理", description = "用户信息管理控制器", tags = "user-controller")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/insertUser")
    @ApiOperation(value = "增加用户", notes = "新增用户")
    public String testAdd(@ApiParam(value = "用户实体", required = true) User user) {
        return "Response success";
    }


    @GetMapping("/getUserById")
    @ApiOperation(value = "通过id获取用户信息", notes = "通过id获取用户信息")
    public ResponseResult getUserById(@RequestParam @ApiParam(value = "用户表id", required = true) Integer id) {

        log.info("前端传入id为{}", id);
        User user = userService.findUserById(id);
        ResponseResult responseResult = ResponseResult.success(user);
        return responseResult;
    }

}